package org.dentalcard.entity;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.io.Serializable;
import java.util.Date;

/**
 * @user: Vladimir Chernishov
 * @date: 25.02.12
 * @time: 18:46
 */
@Embeddable
public class WorkDayPK implements Serializable {
    @Temporal(TemporalType.DATE)
    private Date day;
    private Integer userId;

    public Date getDay() {
        return day;
    }

    public void setDay(Date day) {
        this.day = day;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public int hashCode() {
        return (int) day.hashCode() + userId;
    }

    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (!(obj instanceof WorkDayPK)) return false;
        if (obj == null) return false;
        WorkDayPK pk = (WorkDayPK) obj;
        return pk.userId == userId && pk.day.equals(day);
    }
}
